Namespace My

    ' The following events are availble for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication
        Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
            'TODO: global exception handler - event log, email, clipboard

            e.ExitApplication = True

            'in case there's an exception while initializing, hide the splash screen so it's not on top of the exception dialog
            My.Application.HideSplashScreen()

            Dim frm As New frmException
            frm.txtException.Text = e.Exception.ToString
            frm.ShowDialog()
        End Sub

        Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
            Me.MinimumSplashScreenDisplayTime = 1000

            Return MyBase.OnInitialize(commandLineArgs)
        End Function
    End Class

End Namespace

